package CreateThread;

public class TestYieldAndPriority {
    public static void main(String[] args) {
        Runnable r1 = new Runnable() {
            public void run() {
                int i = 1;
                while (true) {
//                    Thread.yield();
                    System.out.println("thread1---->"+ i++);
                }
            }
        };

        Runnable r2 =()->{
            int i = 1;
            while (true) {
                System.out.println("                   thread2---->"+ i++);
            }
        } ;
        Thread t1 = new Thread(r1,"t1");
        Thread t2 = new Thread(r2,"t2");
        t1.setPriority(Thread.MIN_PRIORITY);
        t2.setPriority(Thread.MAX_PRIORITY);
        t1.start();
        t2.start();
    }
}
